import java.util.Scanner;


public class division {


        /**
         * Chapter 1 program 1: Dividing 2 integers
         * Two integers are input using keyboard and then divided. 
         * Quotient and remaider are shown 
         * @author Vladimir Beliy
         */

	public static void main(String[] args) {
		//initial values of variables
		int dividend=1;
		int divisor=1;
				
		dividend=inputMethod("dividend", dividend);
		divisor=inputMethod("divisor", divisor);
				
						
		
		if ( 0 == divisor){
			System.out.println("Division by zero!");
			}
		else{
			int quotient=dividend/divisor;

			
			printHeaderOfLongDivision(dividend, divisor);

			
			
			int length = String.valueOf(quotient).length();
			int [] array=arrayMethod (length, quotient);
			
      //here lohics to be completed
      
			for (int i=0; i<length; i++){
         int minusPower = (int)(Math.pow(DECIMAL, length-(i+1)));
         int minus =array[i]*divisor*minusPower;
         dividend=dividend-minus;
         System.out.println("_");
         System.out.println(" "+array[i]*divisor);
         System.out.println(" ----");
         System.out.println(" "+dividend);
			}

		}
	}
	
	/**
	 * printHeaderOfLongDivision prints header (no spaces currently are count) 
	 * @param bigValue
	 * @param smallValue
	 */
	public static void printHeaderOfLongDivision(int bigValue, int smallValue){
		System.out.printf("      | %d\n", smallValue);//spaces for four digits 
		System.out.printf(" %d |-------\n", bigValue);
		System.out.printf("      | %d\n",bigValue/smallValue);
	}
	
	/**
	 * inputMethod uses string and int value input via keyboard
	 * @param message
	 * @param valueInput
	 * @return valueInput
	 */
	public static int inputMethod (String message, int valueInput){
		System.out.printf("Enter %s: ", message);
		Scanner scanner= new Scanner(System.in);
		valueInput = scanner.nextInt();
		return valueInput;
	
	/**
	 * arrayMethod generates array from quotient
	 * @param length
	 * @param quotient
	 * @return array
	 */
	public static int [] arrayMethod (int length, int quotient){
		int[] array = new int[length];
		while (length > 0) {
		array[length - 1] = quotient%10;
		quotient /= 10;
		length--;
		}
		return array;
		}

}					